estate_dhimmi = {
	icon = 6
	
	color = { 100 125 150 }

	# Used for when declaring independence
	independence_trigger = {
		has_owner_religion = no
	}
	
	# Is estate kept in control of province on conquest?
	keep_on_conquest = no	

	# Giving territory affects power this much compared to base
	territory_power_modifier = 0.5	

	# If true, country will get estate
	trigger = {	
		NOT = { government = merchant_republic }
		NOT = { government = trading_city }
		NOT = { government = revolutionary_republic }
		NOT = { government = native_council }
		NOT = { government = siberian_native_council }
		NOT = { government = veche_republic }
		NOT = { government = parliamentary_republic }
		NOT = { government = presidental_republic }
		NOT = { government = parliamentary_monarchy }
		NOT = { government = communist_dictatorship }
		NOT = { government = socialist_republic }
		NOT = { government = fascist_dictatorship }
		NOT = { government = military_junta }
		NOT = { government = imperial_roman_republic }
		NOT = { government = plutocratic_republic }
		is_nomad = no
		is_colonial_nation = no
		NOT = { government = celestial_empire }
		NOT = { technology_group = western }
		religion_group = muslim
	}
	
	# If true, province can be granted to estate
	province_trigger = {
		NOT = { religion_group = muslim }
	}	
	
	# Min autonomy in estate provinces
	min_autonomy = 25
	
	# Estate cancels out the following multiplicative local autonomy effects:
	autonomy_does_not_affect = local_tax_modifier

	# These scale with loyalty & power
	country_modifier_happy = {
		technology_cost = -0.1
		tolerance_heathen = 2
	}
	country_modifier_neutral = {
		tolerance_heathen = 2
	}	
	country_modifier_angry = {
		technology_cost = 0.1
		tolerance_heathen = -1
	}
	
	# These do not scale, but only applied in provinces owned by the estate
	province_modifier_happy = {
		local_tax_modifier = 0.33
		local_unrest = -2
		local_missionary_strength = -1		
	}
	province_modifier_neutral = {
		local_tax_modifier = 0.33
		local_missionary_strength = -1		
	}		
	province_modifier_angry = {
		local_unrest = 5
		local_missionary_strength = -1		
	}	
	
	# Influence modifiers
	base_influence = 0
	influence_modifier = {
		desc = EST_VAL_RELIGIOUS_MINORITY
		trigger = {
			any_owned_province = {
				NOT = { religion_group = muslim }
			}
		}
		influence = 10		
	}
	influence_modifier = {
		desc = EST_VAL_RULED_BY_RELIGIOUS_MINORITY
		trigger = {
			NOT = { dominant_religion = ROOT }
			any_owned_province = {
				NOT = { religion_group = muslim }
			}
		}
		influence = 20
	}
	influence_modifier = {
		desc = EST_VAL_OTHER_ESTATE_IN_POWER
		trigger = {
			OR = {
				has_disaster = estate_nobility_disaster
				has_disaster = estate_church_disaster
				has_disaster = estate_burghers_disaster
			}
		}
		influence = -40
	}
	
	#Loyalty Modifiers
	loyalty_modifier = {
		desc = EST_VAL_OTHER_ESTATE_IN_POWER_LOY
		trigger = {
			OR = {
				has_disaster = estate_nobility_disaster
				has_disaster = estate_church_disaster
				has_disaster = estate_burghers_disaster
			}
		}
		loyalty = -20
	}
	
	#Get's the reverse loyalty modifiers for piety compared to Ulema.
	loyalty_modifier = {
		desc = EST_VAL_PIOUS
		trigger = {
			religion_group = muslim
			piety = 0.5
			NOT = { piety = 0.75 }
		}
		loyalty = -5
	}
	loyalty_modifier = {
		desc = EST_VAL_VERY_PIOUS
		trigger = {
			religion_group = muslim
			piety = 0.75
		}
		loyalty = -8
	}
	loyalty_modifier = {
		desc = EST_VAL_NOT_PIOUS
		trigger = {
			religion_group = muslim
			NOT = { piety = -0.5 }
		}
		loyalty = 5
	}
	loyalty_modifier = {
		desc = EST_VAL_VERY_UNPIOUS
		trigger = {
			religion_group = muslim
			NOT = { piety = -0.75 }
		}
		loyalty = 8
	}
	loyalty_modifier = {
		desc = EST_VAL_FULL_HUMANIST
		trigger = {
			full_idea_group = humanist_ideas
		}
		loyalty = 10
	}
	
	# Does the AI want to give any extra territory beyond the minimum?
	ai_territory_modifier = {
		trigger = {
			OR = {
				technology_group = ottoman
				has_idea_group = humanist_ideas
			}
			num_of_cities = 10
		}	
		value = 100 # Code has a sanity check against pushing influence too high
	}	
	
	
	# For province assignment
	ai_grant_province = {
		factor = 1
		modifier = {
			factor = 10
			has_owner_religion = no
			tolerance_to_this = 1
		}		
	}	
	
	# Special interactions
	interaction = {
		name = "RECRUIT_MINISTER"
		icon = 10
		
		years_between_use = 30
		
		potential = {
			NOT = { has_disaster = estate_burghers_disaster }
			NOT = { has_disaster = estate_church_disaster }
			NOT = { has_disaster = estate_nobility_disaster }
		}
		
		trigger = {
			estate_influence = {
				estate = estate_dhimmi
				influence = 40
			}
		}
		
		effect = {
			if = {
				limit = {
					monthly_income = 25
				}
				define_advisor = {
					type = trader
					skill = 3
					discount = yes
				}
			}
			if = {
				limit = { NOT = { monthly_income = 25 } }
				define_advisor = {
					type = trader
					skill = 2
					discount = yes
				}
			}
			add_estate_influence_modifier = {
				estate = estate_dhimmi
				desc = EST_VAL_DHIMMI_MINISTER
				influence = 15
				duration = 10950
			}
			add_estate_loyalty = {
				estate = estate_church
				loyalty = -15
			}
		}
		
		ai_will_do = {
			factor = 0			
		}
	}
	interaction = {
		name = "LIGHTEN_DHIMMI_TAX_BURDEN"
		icon = 8
		
		years_between_use = 10
		
		trigger = {
			estate_influence = {
				estate = estate_dhimmi
				influence = 40
			}
			any_owned_province = {
				has_estate = estate_dhimmi
			}
		}
		
		effect = {
			custom_tooltip = dhimmi_tax_burden_autonomy_tooltip
			hidden_effect = {
				every_owned_province = {
					limit = { has_estate = estate_dhimmi }
					add_local_autonomy = 15
				}
			}
			add_estate_loyalty = {
				estate = estate_dhimmi
				loyalty = 25
			}
			add_estate_influence_modifier = {
				estate = estate_dhimmi
				desc = EST_VAL_LIGHTEN_DHIMMI_TAX_BURDEN
				influence = 10
				duration = 3650
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				estate_loyalty = {
					estate = estate_dhimmi
					loyalty = 30
				}				
			}
		}
	}
	interaction = {
		name = "PROMOTE_DHIMMI_NOBLES"
		icon = 8
		
		years_between_use = 30
		
		potential = {
			NOT = { has_disaster = estate_burghers_disaster }
			NOT = { has_disaster = estate_church_disaster }
			NOT = { has_disaster = estate_nobility_disaster }
		}
		
		trigger = {
			estate_influence = {
				estate = estate_dhimmi
				influence = 40
			}
			estate_loyalty = {
				estate = estate_dhimmi
				loyalty = 30
			}
		}
		
		effect = {
			add_estate_loyalty = {
				estate = estate_dhimmi
				loyalty = 20
			}
			add_country_modifier = {
				name = "dhimmi_nobles"
				duration = 10950
			}
			add_estate_loyalty = {
				estate = estate_church
				loyalty = -15
			}
			add_estate_loyalty = {
				estate = estate_nobles
				loyalty = -15
			}
			add_estate_influence_modifier = {
				estate = estate_dhimmi
				desc = EST_VAL_DHIMMI_NOBLES
				influence = 15
				duration = 10950
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	interaction = {
		name = "RECRUIT_FROM_THE_DHIMMI"
		icon = 12
		
		years_between_use = 10
		
		potential = {
			NOT = { has_disaster = estate_burghers_disaster }
			NOT = { has_disaster = estate_church_disaster }
			NOT = { has_disaster = estate_nobility_disaster }
		}
		
		trigger = {
			estate_influence = {
				estate = estate_dhimmi
				influence = 40
			}
			estate_loyalty = {
				estate = estate_dhimmi
				loyalty = 30
			}
		}
		
		effect = {
			if = {
				limit = {
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 50
						}	
					}
				}
				add_yearly_manpower = 1
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 50
					}
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 75
						}	
					}
				}
				add_yearly_manpower = 1.5
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 75
					}
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 100
						}	
					}
				}
				add_yearly_manpower = 2
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 100
					}
				}
				add_yearly_manpower = 2.5
			}
			add_estate_loyalty = {
				estate = estate_dhimmi
				loyalty = -15
			}
			add_estate_influence_modifier = {
				estate = estate_dhimmi
				desc = EST_VAL_RECRUITED_DHIMMI
				influence = 10
				duration = 3650
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					estate_loyalty = {
						estate = estate_dhimmi
						loyalty = 50
					}	
				}
			}
			modifier = {
				factor = 0
				estate_influence = {
					estate = estate_dhimmi
					influence = 60
				}
			}			
			modifier = {
				factor = 0
				manpower_percentage = 0.25				
			}
		}
	}
	interaction = {
		name = "DEMAND_CONTRIBUTION"
		icon = 9
		
		years_between_use = 10
		
		potential = {
			NOT = { has_disaster = estate_burghers_disaster }
			NOT = { has_disaster = estate_church_disaster }
			NOT = { has_disaster = estate_nobility_disaster }
		}
		
		trigger = {
			estate_loyalty = {
				estate = estate_dhimmi
				loyalty = 30
			}
		}
		
		effect = {
			if = {
				limit = {
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 50
						}	
					}
				}
				add_years_of_income = 0.25
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 50
					}
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 75
						}	
					}
				}
				add_years_of_income = 0.5
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 75
					}
					NOT = {
						estate_influence = {
							estate = estate_dhimmi
							influence = 100
						}	
					}
				}
				add_years_of_income = 0.75
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_dhimmi
						influence = 100
					}
				}
				add_years_of_income = 1
			}		
			add_estate_loyalty = {
				estate = estate_dhimmi
				loyalty = -15 #Take more offense than the Burghers do due to their supposedly protected status.
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					estate_loyalty = {
						estate = estate_dhimmi
						loyalty = 50
					}	
				}
			}
			modifier = {
				factor = 0
				treasury = 1
			}
		}
	}
}